package com.oss.controller.oss;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.DeleteByIdDto;
import com.oss.dto.oss.partnershare.PartnerShareAddDto;
import com.oss.dto.oss.partnershare.PartnerSharePageDto;
import com.oss.dto.oss.partnershare.PartnerShareUpdateDto;
import com.oss.dto.oss.trademanage.TradeManageGetByIDDto;
import com.oss.entity.oss.PartnerShare;
import com.oss.service.oss.PartnerShareService;
import com.oss.vo.oss.partnershare.PartnerShareVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 权益管理
 */
@RestController
@RequestMapping("/partnerShare")
public class PartnerShareController {
    @Autowired
    private PartnerShareService partnerShareService;
    @PostMapping("/selectByPage")
    public BaseResponse<IPage<PartnerShareVO>> selectByPage(@RequestBody @Valid PartnerSharePageDto dto){
        return BaseResponse.success(partnerShareService.selectByPage(dto));
    }
    @PostMapping("/getByID")
    public BaseResponse<PartnerShare> getByID(@RequestBody @Valid TradeManageGetByIDDto dto){
        return BaseResponse.success(partnerShareService.getById(dto.getId()));
    }
    @PostMapping("/add")
    public BaseResponse<String> add(@RequestBody @Valid PartnerShareAddDto dto){
        return BaseResponse.success(partnerShareService.add(dto));
    }
    @PostMapping("/update")
    public BaseResponse<String> updateData(@RequestBody @Valid PartnerShareUpdateDto dto){
        return BaseResponse.success(partnerShareService.updateData(dto));
    }
    @PostMapping("/delete")
    public BaseResponse<String> delete(@RequestBody @Valid DeleteByIdDto dto){
        return BaseResponse.success(partnerShareService.delete(dto));
    }
}